"""
@Project:${2108a 人工智能}
@File:__init__.py.py
@Author:周家昌
@Date:9:07
"""

from flask import Flask
from common.models import db
from syl_project.users import user_bp
from syl_project.oauth_user import oauth_user_bp
from syl_project.course import course_bp
from syl_project.comment import comment_bp
from syl_project.vip import vip_bp
from syl_project.pay.pay import pay_bp
from syl_project.path import path_bp
from flask_cors import CORS
from common.utils.JWT_auth import jwt_authorization

# pip install elasticsearch  # 索引


def create_flask_app(config):
    app = Flask(__name__)
    app.config.from_object(config)
    db.init_app(app)
    CORS(app)
    app.before_request(jwt_authorization)

    app.register_blueprint(user_bp)
    app.register_blueprint(oauth_user_bp)
    app.register_blueprint(course_bp)
    app.register_blueprint(comment_bp)
    app.register_blueprint(vip_bp)
    app.register_blueprint(pay_bp)
    app.register_blueprint(path_bp)
    return app